-
Notifications
You must be signed in to change notification settings - Fork 133
Java: Typed Results #2006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java: Typed Results #2006
Conversation
Co-authored-by: Adrian Görler <[email protected]>
@@ -322,7 +322,7 @@ CqnSelect query = Select.from(BOOKS) | |||
.where(b -> b.ID().ne(bookId).and(similarity.gt(0.9))) | |||
.orderBy(b -> b.get("similarity").desc()); | |||
|
|||
CdsResult<?> similarBooks = db.run(select, CdsVector.of(embedding)); | |||
Result similarBooks = db.run(query, CdsVector.of(embedding)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way that you are changed back these code examples they are now dependant on the setting for typed queries or not. If BOOKS
is used with a LinkedStructuredType
(and usage of CqnSelect
would be avoided via var
) this code example would produce a compilation error now. That's what I tried to avoid by using consistently CdsResult<?>
everywhere, as this is the correct supertype, that will always work.
Otherwise I think it is hard to understand when to use Result
, CdsResult<?>
or CdsResult<Books>
. I think Result
should be largely replaced by CdsResult
to make things more consistent.
This also applies to other locations changed back within these diffs: https://github.com/capire/docs/pull/2006/files/f875bf04d9ee79f64002594e9a9f6cf7b50c670d..45bb6fe5a63d5e2a16d397d718374772d1270669
@@ -397,7 +397,7 @@ To select the mapping elements of a managed association, simply add the [associa | |||
CqnSelect select = Select.from(BOOKS).byId(123) | |||
.columns(b -> b.author()); | |||
|
|||
CdsData row = persistence.run(select).single(); | |||
Row row = persistence.run(select).single(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above applies here, if select would retain Select<Books>
, this would result in a compilation error. I think CdsData
should be preferred over Row
, as again it is the common supertype of all variants.
No description provided.